#!/usr/bin/python

#foo() #foo nije definisan

def foo():
  print "KING"

foo()

def sum(a,b):
  return a+b

print(sum(1,1))
print(sum(1,5))

def mul(a,b):
  return a*b

def pow(a):
  return mul(a,a)

def pow1(a,mul1):
  return mul1(a,a)

def mul1(a,b):
  sum=0
  for i in range(0,b):
    sum+=a
  return sum

print(pow(4))
print(pow1(4,mul1))


### prenosenje po vrednosti
print("Test prenosa po vrednosti")
a=4

def changeA(b):
  print b
  b=11
  print b

changeA(a)

print(a)

def changeA1(b):
  global a #koriscenje global direktive
  a=b

changeA1(10)
print(a)

######## pass by reference
array1 = [1,2,3]

def change_array(array):
  if len(array) > 0:
    array[0]=3

print(array1)
change_array(array1)
print(array1)

###simuliranje menadzera iz c#
def fun1(a):
  return a+4

def fun2(a):
  return a+5

def fun3(a):
  return a+6

#problem se javljao kada su kljucevi bili stringovi
#onda nije bilo sortirano prema nacinu na koji su
#funkcije dodate u recnik
manager = {}
manager[1] = fun1
manager[2] = fun2
manager[3] = fun3

print(manager)

for k,v in manager.iteritems():
  print(manager[k](4))


print(manager.keys())
keyz = manager.keys()
keyz.sort()
print(keyz)

for i in keyz:
  print manager[i](4)